#ifndef PREFERENCES_H
#define PREFERENCES_H
#include <direct.h>
#include <stdio.h>
#include <cstring>
#include <stdlib.h>
#include <math.h>;
#include <stdint.h>
struct Preferences{
	int PositivePeak;// Bool = 0 if No, != 0 Yes
	int NegativePeak;// Bool = 0 if No, != 0 Yes
	int RenameFiles; // Bool = 0 if No, != 0 Yes
	char OutputFolder[512];
	int Channel;// raw data channel <-- global channel, ch= will override
	int blockSize;
	int RenameFiles_AverageFrequency;
	char RenameFiles_Prefix[200];
	int RenameFiles_NoteName;
	
	int AmplitudeGraph;
	int Resynthesize;
	int Normalize_for_Detection;
	int TestChannel;
	//SigMund
	int Sigmund_Npts;
	int Sigmund_HopSize;
	int Sigmund_Sinewave;
	int pitchGraph_Sig;// Bool = 0 if No, != 0 Yes
	uint32_t DelayCompensation_Sig;
	//int Sigmund;
	//Helmholtz
	int Helmholtz_Sinewave;// Bool = 0 if No, != 0 Yes
	float Helmholtz_Fidelity;// Float 0 to 1 
	int pitchGraph_Hel;// Bool = 0 if No, != 0 Yes
	//int Helmholtz;
	//Noise and harmonic
	int Window_Type;
	int Overlap_Separate;
	int BlockSize_Separate;
	int MaxFreq_Separate;
	float BandFrequency_Separate;


	int Noise_Channel;
	int Fundamental;
	int Harmonics;
	int Combined;
	int Original;
	int Recreate_Harmonics;
	int Individual_Harmonics;
	
private:
	int validateOutputFolder;
public:
	int getNumberChannelAdded(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		//if (Noise_Channel) num++;
		if (PositivePeak) num++;
		if (NegativePeak) num++;
		if (pitchGraph_Sig) num++;
		if (pitchGraph_Hel) num++;
		if (Sigmund_Sinewave) num++;
		if (Helmholtz_Sinewave) num++;
		
		return num;
	}
	/*int getNumberChannelNoise(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		if (pitchGraph_Sig) num++;
		if (PositivePeak) num++;
		if (NegativePeak) num++;
		if (Noise_Channel) num++;
		return num - 1;
	}*/
	int getNumberChannelHarmonic(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		if (pitchGraph_Sig) num++;
		if (PositivePeak) num++;
		if (NegativePeak) num++;
		return num - 1;
	}
	int getNumberChannelNag(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		if (pitchGraph_Sig) num++;
		if (PositivePeak) num++;
		if (NegativePeak) num++;
		return num -1;
	}
	int getNumberChannelPos(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		if (pitchGraph_Sig) num++;
		if (PositivePeak) num++;
		return num - 1;
	}
	int getNumberChannelPitchChanHel(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		return num -1;
	}
	int getNumberChannelPitchChanSig(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		if (pitchGraph_Hel) num++;
		if (pitchGraph_Sig) num++;
		return num - 1;
	}
	int getNumberChannelSinChanSig(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		if (Sigmund_Sinewave) num++;
		return num - 1;
	}
	int getNumberChannelSinChanHel(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		if (Helmholtz_Sinewave) num++;
		return num -1;
	}
	int getNumberChannelResynthesize(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		if (Resynthesize) num++;
		return num - 1;
	}
	int getNumberChannelAmplitudeGraph(){
		int num = 0;
		if (TestChannel) num++;
		if (AmplitudeGraph) num++;
		return num - 1;
	}
	int getNumberTestChannel(){
		int num = 0;
		if (TestChannel) num++;
		return num - 1;
	}
	int isAddNegative(){
		return NegativePeak;
	}
	int isAddPositive(){
		return PositivePeak;
	}
	int isValidateOutputFolder(){
		if (validateOutputFolder == -1){
			int error = mkdir(OutputFolder);
			if (error == 0){
				printf("Create output folder: %s \n", OutputFolder);
				validateOutputFolder = 1;
			}
			else if (errno == 17){
				validateOutputFolder = 1;
			}else
				validateOutputFolder = 0;
		}
		return validateOutputFolder;
	}


	Preferences(){
		PositivePeak = 0;
		NegativePeak = 0;
		RenameFiles = 0;
		memset(OutputFolder, 0, 512);
		memset(RenameFiles_Prefix, 0, 200);
		blockSize = 0;
		Channel = 0;
		pitchGraph_Hel = 0;
		Helmholtz_Sinewave = 0;
		Helmholtz_Fidelity = 0.95;

		pitchGraph_Sig = 0;
		Sigmund_Npts = 0;
		Sigmund_HopSize = 0;
		Sigmund_Sinewave = 0;
		DelayCompensation_Sig = 0;
		RenameFiles_AverageFrequency = 0;
		Fundamental = 0;
		validateOutputFolder = -1;
		AmplitudeGraph = 0;
		Resynthesize = 0;
		Normalize_for_Detection = 0; 
		TestChannel = 0;
		Window_Type = 0;


		Noise_Channel = 0;
		Fundamental = 0;
		Harmonics = 0;
		Combined = 0;
		Original = 0;
		Recreate_Harmonics = 0;
		Individual_Harmonics = 0;

	}
};
Preferences *LoadPreference(char *path);
#endif // ! PREFERENCES_H